<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta charset="utf-8">
	<title></title>
	<meta name="keywords" content="">
	<meta name="description" content="">
	<meta name="author" content="">
	<link href="css/daterangepicker.min.css" rel="stylesheet">
	<link rel="stylesheet" href="css/main.css">

	<script src="js/vue.js"></script>
	<script src="https://unpkg.com/element-ui/lib/index.js"></script>
	<script src="js/request.js"></script>


	<!--[if lt IE 9]>
	<script src="js/html5shiv.min.js"></script>
	<script src="js/respond.min.js"></script>
<![endif]-->
<meta name="renderer" content="webkit">
<link rel="shortcut icon" href="favicon.ico">
</head>
<body>
<div id="apps">
	<header id="header"></header>
	<div class="header-space"></div>

	<section class="section61">
		<div class="content">
			<div class="search-box">
				<div class="tips">
					<span style="cursor: pointer;" :class="isUser ? 'on' : ''" @click="goTab(true)">职位（{{total}}）</span>
					<span style="cursor: pointer;" :class="isUser ? '' : 'on'" @click="goTab(false)">公司（{{companyTotal}}）</span>
				</div>
				<div class="con">
					<input type="text" class="input" placeholder="请输入职位/公司名称" v-model="param.keyword">
					<input type="submit" value="搜索" class="btn btn-white" @click="goSearch">
				</div>
				<p>热门搜索：{{paramList.hot_search}}
					<a style="cursor: pointer;" v-for="(list, index) in paramList.hot_keyword" :key="'a'+index" @click="param.keyword = list">{{list}}{{index < (paramList.hot_keyword.length - 1) ? '、' : ''}}&nbsp;</a>
				</p>
			</div>
		</div>
	</section>

	<section class="section251">
		<div class="content">
			<div class="filter">
				<div class="item" :class="isItem ? 'auto' : ''">
					<b class="tt">工作地址</b>
					<div class="con" :class="isItem ? 'two' : ''">
						<a style="cursor: pointer" :class="param.area === '' ? 'on' : ''" @click="searchAddressFun('', 'area')">全部</a>
						<template v-for="item in paramList.region">
							<a v-for="(list, index) in item.children || []" :key="list.id" @click="searchAddressFun(list, 'area')" :class="list.id === param.area ? 'on' : ''" style="cursor: pointer;">{{list.region_name ? list.region_name : '全部'}}</a>
						</template>
					</div>
					<a style="cursor: pointer;" class="btn-more" @click="isItem = isItem ? false : true">查看更多</a>
				</div>
				<div class="item" v-if="addressDate">
					<b class="tt"></b>
					<div class="con">
<!--						{{addressDate}}-->
						<a style="cursor: pointer" :class="param.area === addressDate.id ? 'on' : ''" @click="searchFun(addressDate.id, 'area')">全部</a>
						<a v-for="(list, index) in addressDate.children || []" :key="'c'+index" @click="searchFun(list.id, 'area')" :class="list.id === param.area ? 'on' : ''" style="cursor: pointer;">{{list.region_name ? list.region_name : '全部'}}</a>
<!--						<a v-for="(list, index) in paramList.region" :key="index" @click="searchFun(list.id, 'area')" :class="list.id === param.area ? 'on' : ''" style="cursor: pointer;">{{list.region_name ? list.region_name : '全部'}}</a>-->
					</div>
				</div>
				<div class="item" v-if="isUser">
					<b class="tt">年限</b>
					<div class="con">
						<a :class="!param.experience ? 'on' : ''" @click="searchFun('', 'experience')" style="cursor: pointer;">全部</a>
						<a v-for="(list, index) in paramList.experience" :key="'d'+index" @click="searchFun(list.id, 'experience')" :class="list.id === param.experience ? 'on' : ''" style="cursor: pointer;">{{list.min == 0 && list.max == 1 ? '1年以下' : list.min > 0 && list.max > 1 ? list.min + '到' + list.max + '年' : ''}}</a>
					</div>
				</div>
				<div class="item" v-if="isUser">
					<b class="tt">学历</b>
					<div class="con">
						<a :class="!param.education ? 'on' : ''" @click="searchFun('', 'education')" style="cursor: pointer;">全部</a>
						<a v-for="(list, index) in paramList.education" :key="'e'+index" @click="searchFun(list.id, 'education')" :class="list.id === param.education ? 'on' : ''" style="cursor: pointer;">{{list.name ? list.name : ''}}</a>
					</div>
				</div>
				<div class="item" v-if="isUser">
					<b class="tt">薪资范围</b>
					<div class="con">
						<a :class="!param.salary ? 'on' : ''" @click="searchFun('', 'salary')" style="cursor: pointer;">全部</a>
						<a v-for="(list, index) in paramList.salary" :key="'xz'+index" @click="searchFun(list.max, 'salary')" :class="list.max === param.salary ? 'on' : ''" style="cursor: pointer;">{{list.min + 'k - ' + list.max + 'k'}}</a>
					</div>
				</div>
				<div class="item" v-if="isUser">
					<b class="tt">岗位性质</b>
					<div class="con">
						<a :class="!param.type ? 'on' : ''" @click="searchFun('', 'type')" style="cursor: pointer;">全部</a>
						<a v-for="(list, index) in paramList.nature" :key="'gwxz'+index" @click="searchFun(list.id, 'type')" :class="list.id === param.type ? 'on' : ''" style="cursor: pointer;">{{list.name ? list.name : ''}}</a>
					</div>
				</div>
				<div class="item">
					<b class="tt">企业性质</b>
					<div class="con">
						<a :class="!param.enterprise_type ? 'on' : ''" @click="searchFun('', 'enterprise_type')" style="cursor: pointer;">全部</a>
						<a v-for="(list, index) in paramList.type" :key="'qxxz'+index" @click="searchFun(list.id, 'enterprise_type')" :class="list.id === param.enterprise_type ? 'on' : ''" style="cursor: pointer;">{{list.name ? list.name : ''}}</a>
					</div>
				</div>
				<div class="item">
					<b class="tt">企业规模</b>
					<div class="con">
						<a :class="!param.size ? 'on' : ''" @click="searchFun('', 'size')" style="cursor: pointer;">全部</a>
						<a v-for="(list, index) in paramList.size" :key="'qygm'+index" @click="searchFun(list.id, 'size')" :class="list.id === param.size ? 'on' : ''" style="cursor: pointer;">{{list.name ? list.name : ''}}</a>
					</div>
				</div>
				<div class="item">
					<b class="tt">企业标签</b>
					<div class="con">
						<a :class="!param.welfare ? 'on' : ''" @click="searchFun('', 'welfare')" style="cursor: pointer;">全部</a>
						<a v-for="(list, index) in paramList.tag" :key="'qybq'+index" @click="searchFun(list.id, 'welfare')" :class="list.id === param.welfare ? 'on' : ''" style="cursor: pointer;">{{list.name ? list.name : ''}}</a>
					</div>
				</div>
			</div>
		</div>
	</section>
	<section class="section252">
		<div class="content" v-if="isUser">
			<div class="list" v-loading="listLoading">

				<div class="item" v-for="(list, index) in dateList" :key="'aa'+index">
					<div class="con" @click="goUrl('07.html?id=' + list.id)">
						<a :href="'07.html?id=' + list.id">
						<h3><a :href="'07.html?id=' + list.id"><b>{{list.name}}</b></a> <span class="orange e2">{{list.salary_min}}-{{list.salary_max}}K</span></h3>
						<p>{{matchFun(paramList.education || [], list.education_id, 'id', 'name')}}及以上&nbsp;&nbsp;|&nbsp;&nbsp;{{matchFun(paramList.nature || [], list.type, 'id', 'name')}}&nbsp;&nbsp;|&nbsp;&nbsp;{{matchFun(paramList.experience || [], list.experience_config_id, 'id', 'min') + '-' + matchFun(paramList.experience || [], list.experience_config_id, 'id', 'max')}}年</p>
						<p>
							<span class="tag" v-for="(item, itemIndex) in list.recruit_welfare || []" :key="'bb'+itemIndex" v-if="itemIndex < 4">
								{{matchFun(paramList.tag || [], item.welfare_id, 'id', 'name')}}
							</span>
						</p>
						</a>
					</div>
					<div class="con" @click="goUrl('08.html?id=' + list.enterprise_id)">
						<h3><a :href="'08.html?id=' + list.enterprise_id">{{list.enterprise && list.enterprise.name ? list.enterprise.name : ''}}</a></h3>
						<p>{{matchAddressFun(paramList.region, list.area_id)}}&nbsp;&nbsp;|&nbsp;&nbsp;{{matchFun(paramList.type || [], list.enterprise.type_id, 'id', 'name')}}</p>
						<!-- 暂缺 -->
						<p><time v-if="list.updated_at">{{timeFun(list.updated_at)}}</time></p>
					</div>
					<div class="user">
						<a :href="'08.html?id='+list.enterprise.id">
							<img :src="list.user && list.user.logo ? list.user.logo : 'images/noUser.png'" alt="" class="face">
							<h4>{{list.user && list.user.name ? list.user.name : ''}}</h4>
							<p v-if="list.user && list.user.user && list.user.user.login_time">{{timeFun(list.user.user.login_time)}}</p>
						</a>
					</div>
					<a :href="'05.html?myuid=' + list.uid" class="btn">立即沟通</a>
				</div>

			</div>
			<div class="g-prvNxt" v-show="total">
				<a style="cursor: pointer;" @click="pageJumpFun('min')" class="prev">&nbsp;</a>
				<a style="cursor: pointer;" :class="param.page == list ? 'on' : ''" v-for="list in Math.ceil(total / param.num)" :key="'cc'+list" @click="pageJumpFun(list)">{{list}}</a>
				<a style="cursor: pointer;" class="next" @click="pageJumpFun('max')">&nbsp;</a>
				<select v-model="param.num">
					<option value="15">15条/页</option>
					<option value="20">20条/页</option>
					<option value="30">30条/页</option>
					<option value="40">40条/页</option>
					<option value="50">50条/页</option>
				</select>
				跳至
				<input type="text" v-model="param.page" class="input">
				页
				<input type="submit" value="确定" class="btn" @click="getList">
			</div>
		</div>
		<div class="content" v-else>
			<div class="list">
				<div class="item company-list" v-for="(list, index) in companyList" :key="'aaa'+index" @click="goUrl('08.html?id=' + list.id)">
					<img :src="list.logo" class="company-img">
					<div class="company-center">
						<div class="company-title">{{list.name}}</div>
						<div class="company-address">{{matchAddressFun(paramList.region || [], list.area_id)}}&nbsp;&nbsp;|&nbsp;&nbsp;{{matchFun(paramList.type || [], list.type_id, 'id', 'name')}}</div>
						<div class="company-number">{{matchFun(paramList.size || [], list.size_id, 'id', 'name')}}</div>
					</div>
					<div class="company-bottom">{{list.recruit_count}}在招职位</div>
				</div>
			</div>
			<div class="g-prvNxt" v-show="companyTotal">
				<a style="cursor: pointer;" @click="pageJumpFun('min')" class="prev">&nbsp;</a>
				<a style="cursor: pointer;" :class="param.page == list ? 'on' : ''" v-for="list in Math.ceil(companyTotal / param.num)" :key="'ee'+list" @click="pageJumpFun(list)">{{list}}</a>
				<a style="cursor: pointer;" class="next" @click="pageJumpFun('max')">&nbsp;</a>
				<select v-model="param.num">
					<option value="15">15条/页</option>
					<option value="20">20条/页</option>
					<option value="30">30条/页</option>
					<option value="40">40条/页</option>
					<option value="50">50条/页</option>
				</select>
				跳至
				<input type="text" v-model="param.page" class="input">
				页
				<input type="submit" value="确定" class="btn" @click="getCompany">
			</div>
		</div>
	</section>

	<div style="height: 151px">
		<footer>
			<div class="content">
				<div class="menu">
					<a href="20.html">联系我们</a>
					<a href="23.html">意见反馈</a>
					<a href="24.html">关于我们</a>
				</div>
				<div class="cpt">
					Copyright &#169 2019 人员招聘 ICP备14013400号-1京ICP证150920号 电子营业执照 <a href="">京公网安备11010502031234</a> 首都网警 <a href="">人力资源服务许可证</a>
				</div>
			</div>
		</footer>
	</div>
</div>
<script src="js/lcommon.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/slide.min.js"></script>
<script src="js/polyfill.min.js"></script>
<script src="js/jquery.nicescroll3.7.6.min.js"></script>
<script src="js/main.js"></script>
<style rel="stylesheet" type="text/css">
	.two {
		max-height: 200px;
		overflow-y: auto;
	}
	.company-list {
		display: flex;
		align-items: center;
	}
	.company-img {
		width: 79px;
		height: 79px;
		margin-right: 20px;
	}
	.company-center {
		width: 352px;
	}
	.company-title {
		font-size: 18px;
		color: #2F3134;
	}
	.company-address {
		padding-top: 10px;
		padding-bottom: 10px;
	}
	.company-address, .company-number {
		font-size: 12px;
		color: #888B8E;
	}
	.company-bottom {
		font-size: 16px;
		color: #2F3134;
	}
	.section252 .item .btn {
		right: 180px;
	}
	.section252 .item:hover .user {
		display: block;
	}
</style>
<script>
	$(function(){
		$("header .menu li").eq(1).addClass('on');
		$("#header").load("./lcommon/header.html");
	})
	function GetQueryValue(queryName) {
		var query = decodeURI(window.location.search.substring(1));
		var vars = query.split("&");
		for (var i = 0; i < vars.length; i++) {
			var pair = vars[i].split("=");
			if (pair[0] == queryName) { return pair[1]; }
		}
		return null;
	}

	var vm = new Vue({
		el: '#apps',
		data() {
			return {
				isItem: false,
				total: 0, // 总条数
				isUser: true,
				'enterprise_total': 0,
				param: {
					num: 15,
					page: 1, //	页码	默认1
					keyword: '', //	搜索关键词
					experience: '', //	工作年限id
					education: '', //	教育程度id
					salary: '', //	最高期望薪资	单位K
					type: '', //	工作性质
					enterprise_type: '', //	企业性质id
					size: '', //	企业规模id
					area: '', //	地区id	不限 传上一级(市级)的地区id
					welfare: '' //	福利标签id
				},
				paramList: [],	// 查询到的列表数据
				dateList: [],	// 列表数据
				userInfo: {},	// 个人数据

				addressDate: null,	// 时间专用

				companyList: [],
				companyTotal: 0,

				listLoading: false
			}
		},
		created() {
			let key = GetQueryValue('key');
			if (key) {
				this.param.keyword = key;
			}
			this.getInfo();
			this.getBasis();
			this.getList();
			this.getCompany();
		},
		methods: {
            goUrl(url) {
                // this.$router.push(url);
                window.open(url);
            },
			goSearch() {
				if (this.isUser) {
					this.getList();
				} else {
					this.getCompany();
				}
			},
			goTab(val) {
				this.isUser = val;
				this.param.page = 1;
				if (val) {
					this.getList();
				} else {
					this.getCompany();
				}
			},
			searchAddressFun(list, name) {
				this.searchFun(list.id, name);
				this.addressDate = list;
			},
			timeFun(val) {
				var timestamp = new Date(val).getTime();

				var minute = 1000 * 60;
				var hour = minute * 60;
				var day = hour * 24;
				var halfamonth = day * 15;
				var month = day * 30;
				var year = day * 365;
				var now = new Date().getTime();
				var diffValue = now - timestamp;
				var result;
				if (diffValue < 0) {
					return;
				}
				var yearC = diffValue / year;
				var monthC = diffValue / month;
				var weekC = diffValue / (7 * day);
				var dayC = diffValue / day;
				var hourC = diffValue / hour;
				var minC = diffValue / minute;
				if (yearC >= 1) {
					result = "" + parseInt(yearC) + "年前";
				} else if (monthC >= 1) {
					result = "" + parseInt(monthC) + "月前";
				} else if (weekC >= 1) {
					result = "" + parseInt(weekC) + "周前";
				} else if (dayC >= 1) {
					result = "" + parseInt(dayC) + "天前";
				} else if (hourC >= 1) {
					result = "" + parseInt(hourC) + "小时前";
				} else if (minC >= 1) {
					result = "" + parseInt(minC) + "分钟前";
				} else
					result = "刚刚";
				return result;
			},
			searchFun(val, name) {
				this.param[name] = val;
				this.param.page = 1;
				this.getList();
			},
			// 页数加减 or 跳页
			pageJumpFun(page) {
				if (page === 'min') {
					if (this.param.page !== 1) {
						this.param.page -= 1;
						if (this.isUser) {
							this.getList();
						} else {
							this.getCompany();
						}
					}
				} else if (page === 'max') {
					if (this.param.page * this.param.num < this.total) {
						this.param.page += 1;
						if (this.isUser) {
							this.getList();
						} else {
							this.getCompany();
						}
					}
				} else {
					this.param.page = page;
					if (this.isUser) {
						this.getList();
					} else {
						this.getCompany();
					}
				}
			},
			// 地址查询
			matchAddressFun(list, val) {
				if (!Array.isArray(list)) return '';
				let str = this.addressSearch(list, val);
				return str;
			},
			addressSearch(list, val) {
				for (let i = 0; i < list.length; i++) {
					if (Number(list[i].id) === Number(val)) {
						return list[i].region_name;
					} else if (list[i].children && list[i].children.length > 0) {
						let str = this.addressSearch(list[i].children, val);
						if (str) return list[i].region_name + '_' + str;
					}
				}
				return '';
			},
			// 匹配方法 list 需要匹配的列表 val 匹配的值 item 匹配的字段
			matchFun(list, val, item, name) {
				for (let i = 0; i < list.length; i++) {
					if (item) {
						if (list[i][item] == val) {
							return list[i][name];
						}
					} else {}
				}
			},
			// 个人信息查询
			getInfo() {
				let url = 'person/my/info';
				request(url, 'GET', '', res => {
					console.log('个人信息', res);
					if (res.code === 1) {
						this.userInfo = res.data.info;
					}
				}, err => {
					console.log(err)
				})
			},
			// 查询基础数据
			getBasis() {
				let url = 'person/index/prepare';
				request(url, 'GET', '', res => {
					console.log('查询结果', res);;
					if (res.code === 1) {
						this.paramList = res.data;
					}
				}, function(err) {
					console.log('错误', err)
				})
			},
			// 查询公司列表
			getCompany() {
				let url = 'person/recruit/company';
				let params = {
					page: this.param.page,
					keyword: this.param.keyword,
					enterprise_type: this.param.enterprise_type,
					size: this.param.size,
					area: this.param.area,
					welfare: this.param.welfare
				};
				let param = {};
				for (let i in params) {
					if (params[i] || params[i] === 0) {
						param[i] = params[i];
					}
				}
				request(url, 'GET', param, res => {
					if (res.code === 1) {
						console.log(res);
						this.companyList = res.data.company;
						this.companyTotal = res.data.total;
					}
				}, err => {
					console.log(err)
				})
			},
			// 查询岗位列表
			getList() {
				let url = 'person/recruit';
				let params = {};
				for (let i in this.param) {
					if (this.param[i] !== '') {
						params[i] = this.param[i];
					}
				}
				this.listLoading = true;
				request(url, 'GET', params, res => {
					console.log('岗位列表', res);
					if (res.code === 1) {
						this.total = res.data.total;
						this.dateList = res.data.recruit;
						if (res.data.enterprise_total) this.enterprise_total = res.data.enterprise_total;
					}
					this.listLoading = false;
				}, function(err) {
					this.listLoading = false;
					console.log(err)
				})
			}
		}
	})
</script>
</body>
</html>
